const obj = {
  name: "zhangsan",
  age: 18,
  habbit: ["mmmm", "jquery", "coffee"],
};

function getPrototy<T extends object, Key extends keyof T>(
  obj: T,
  key: Key,
): T[Key] {
  return obj[key];
}

const myname = getPrototy(obj, "name");

console.log(myname);

const age = getPrototy(obj, "age");

const habbit = getPrototy(obj, "habbit");

const mes = "hello word";

const obj2 = {
  msg: "aaaa",
  dd: 123,
};

function test(arg: string) {
  console.log(arg);
  console.log(new.target);
  // console.log(this);
  // console.log(new.target === this);
}

// new test('aaa');

// 下面的代码能看得明白吗？
type ParseParam<Param extends string> =
  Param extends `${infer Key}=${infer Value}`
    ? {
        [K in Key]: Value;
      }
    : {};


type MergeValues<One, Other> = One extends Other
  ? One
  : Other extends unknown[]
    ? [One, ...Other]
    : [One, Other];


type MergeParams<
  OneParam extends Record<string, any>,
  OtherParam extends Record<string, any>,
> = {
  [Key in keyof OneParam | keyof OtherParam]: Key extends keyof OneParam
    ? Key extends keyof OtherParam
      ? MergeValues<OneParam[Key], OtherParam[Key]>
      : OneParam[Key]
    : Key extends keyof OtherParam
      ? OtherParam[Key]
      : never;
};


type ParseQueryString<Str extends string> =
  Str extends `${infer Param}&${infer Rest}`
    ? MergeParams<ParseParam<Param>, ParseQueryString<Rest>>
    : ParseParam<Str>;

